package com.liull.netty.nio.helloworld;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.string.StringEncoder;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 12:39 2021/7/24
 * @Modified By:
 */
public class HelloClient {
    public static void main(String[] args) throws InterruptedException {
        final ChannelFuture future = new Bootstrap().group(new NioEventLoopGroup())
                .channel(NioSocketChannel.class)
                .handler(new ChannelInitializer<NioSocketChannel>() {
                    @Override
                    protected void initChannel(NioSocketChannel ch) throws Exception {
                        ch.pipeline().addLast(new StringEncoder());
                    }
                })
                .connect("localhost", 8989).sync();
        future.channel().writeAndFlush("李燕林小宝贝儿你好");
    }
}
